package com.shujia.flink.source
import  org.apache.flink.streaming.api.scala._
object Demo01Source {
  def main(args: Array[String]): Unit = {


    //创建flink环境
    val env: StreamExecutionEnvironment = StreamExecutionEnvironment.getExecutionEnvironment

    /**
     * 1.基于本地集合构建DataStream --有界流
     *
     */
    val listDS: DataStream[Int] = env.fromCollection(List(1, 5, 9, 8, 4))

    // listDS.print()


    /**
     * 2.基于文件source  --- 有界流
     *
     */
    val TestDS: DataStream[String] = env.readTextFile("data/students.txt")


    // TestDS.print()


    /**
     * 3.读取socket   ---无界流
     */
    val socketDS: DataStream[String] = env.socketTextStream("master", 8888)
    socketDS.print()


    /**
     * 4.自定义
     * kafka
     */



    env.execute()

  }

}
